package com.github.lzm320a99981e.component.dataautomation;

import org.springframework.retry.annotation.Recover;

/**
 * 抽取器公共信息
 *
 * @param <I>
 * @param <O>
 */
public abstract class AbstractExtractor<I, O> implements Extractor<I, O> {
    private String apiCode;

    public AbstractExtractor() {
        this.apiCode = getClass().getSimpleName().replace(Extractor.class.getSimpleName(), "");
    }

    protected String getApiCode() {
        return apiCode;
    }

    @Recover
    protected O recover(Exception e) {
        DataAutomationContext.getCurrentContext().setTermination(true);
        DataAutomationContext.getCurrentContext().setExtractRecoverExceptionStackTrace(e);
        return null;
    }
}
